
using System;
using Unity.Mathematics;
using WorldMapBase.Layer;
using WorldMapBase.LOD;

namespace WorldMap.TouchCamera
{
    public class WorldGlobalLodListener : Layer,ILODListener
    {

        private static Action<int, int> OnLodLevelNotify;
        private static Action<int, float> OnLodPercentNotify;


        public static void AddLodLevelListener(Action<int, int> listener)
        {
            Debug.Log("添加lod层级改变监听");
            OnLodLevelNotify += listener;
        }

        public static void RemoveLodLevelListener(Action<int, int> listener)
        {
            OnLodLevelNotify -= listener;
        }

        public static void AddLodPercentListener(Action<int, float> listener)
        {
            OnLodPercentNotify += listener;
        }

        public static void RemoveLodPercentListener(Action<int, float> listener)
        {
            OnLodPercentNotify -= listener;
        }
        
        
        protected override void OnCreate()
        {
            
        }

        protected override void OnDestroy()
        {
            
        }

        protected override void OnUpdateViewRect(int4 viewRect)
        {
            
        }
        
        public void OnLODLevelChange(int currentLodLevel, int lastLodLevel)
        {
            //UnityEngine.Debug.LogError(currentLodLevel);
            OnLodLevelNotify?.Invoke(currentLodLevel,lastLodLevel);
        }

        public void OnNextLODPercentUpdate(int lodLevel, float nextLevelPercent)
        {
            //UnityEngine.Debug.LogError(nextLevelPercent);
            OnLodPercentNotify?.Invoke(lodLevel,nextLevelPercent);
        }
    }
}